package com.monitor.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.monitor.system.domain.vo.LogInspectionVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.monitor.common.annotation.Log;
import com.monitor.common.core.controller.BaseController;
import com.monitor.common.core.domain.AjaxResult;
import com.monitor.common.enums.BusinessType;
import com.monitor.system.domain.LogInspection;
import com.monitor.system.service.ILogInspectionService;
import com.monitor.common.utils.poi.ExcelUtil;
import com.monitor.common.core.page.TableDataInfo;

/**
 * 日志巡检Controller
 * 
 * @author monitor
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/system/inspection")
public class LogInspectionController extends BaseController
{
    @Autowired
    private ILogInspectionService logInspectionService;

    /**
     * 查询日志巡检列表
     */
    @ApiOperation("查询日志巡检列表")
    @PreAuthorize("@ss.hasPermi('system:inspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(LogInspection logInspection)
    {
        startPage();
        List<LogInspection> list = logInspectionService.selectLogInspectionList(logInspection);
        return getDataTable(list);
    }

    /**
     * 导出日志巡检列表
     */
    @ApiOperation("导出日志巡检列表")
    @PreAuthorize("@ss.hasPermi('system:inspection:export')")
    @Log(title = "日志巡检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LogInspection logInspection)
    {
        List<LogInspection> list = logInspectionService.selectLogInspectionList(logInspection);
        ExcelUtil<LogInspection> util = new ExcelUtil<LogInspection>(LogInspection.class);
        util.exportExcel(response, list, "日志巡检数据");
    }

    /**
     * 获取日志巡检详细信息
     */
    @ApiOperation("获取日志巡检详细信息")
    @PreAuthorize("@ss.hasPermi('system:inspection:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(logInspectionService.selectLogInspectionById(id));
    }

    /**
     * 新增日志巡检
     */
    @ApiOperation("新增日志巡检")
    @PreAuthorize("@ss.hasPermi('system:inspection:add')")
    @Log(title = "日志巡检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LogInspection logInspection)
    {
        return toAjax(logInspectionService.insertLogInspection(logInspection));
    }

    /**
     * 修改日志巡检
     */
    @ApiOperation("修改日志巡检")
    @PreAuthorize("@ss.hasPermi('system:inspection:edit')")
    @Log(title = "日志巡检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LogInspection logInspection)
    {
        return toAjax(logInspectionService.updateLogInspection(logInspection));
    }

    /**
     * 删除日志巡检
     */
    @ApiOperation("删除日志巡检")
    @PreAuthorize("@ss.hasPermi('system:inspection:remove')")
    @Log(title = "日志巡检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(logInspectionService.deleteLogInspectionByIds(ids));
    }

    /**
     * 查询日志
     */
    @ApiOperation("查询日志巡检列表(包含部门信息)")
//    @PreAuthorize("@ss.hasPermi('system:inspection:selectLogInspectionDeptList')")
    @GetMapping("/selectLogInspectionDeptList")
    public TableDataInfo selectLogInspectionDeptList(LogInspectionVo logInspection)
    {
        startPage();
        List<LogInspection> list = logInspectionService.selectLogInspectionDeptList(logInspection);
        return getDataTable(list);
    }

    /**
     * 查询日志巡检列表
     */
    @ApiOperation("查询数据恢复列表)")
    @PreAuthorize("@ss.hasPermi('system:inspection:selectLogInspectionDataList')")
    @GetMapping("/selectLogInspectionDataList")
    public TableDataInfo selectLogInspectionDataList(LogInspectionVo logInspection)
    {
        startPage();
        List<LogInspection> list = logInspectionService.selectLogInspectionDataList(logInspection);
        return getDataTable(list);
    }

}
